package cn.itcast.service.system.impl;

import cn.hutool.core.util.IdUtil;
import cn.itcast.dao.system.SysLogDao;
import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    private SysLogDao sysLogDao;

    @Override
    public List<SysLog> findAll(String companyId) {
        return sysLogDao.findAll(companyId);
    }

    @Override
    public void save(SysLog log) {
        log.setId(IdUtil.simpleUUID());
        sysLogDao.save(log);
    }

    @Override
    public PageInfo findByPage(Integer pageNum, Integer pageSize, String companyId) {
        PageHelper.startPage(pageNum, pageSize);

        List<SysLog> list = sysLogDao.findAll(companyId);

        return new PageInfo(list);
    }
}
